<!--[if lt IE 9]>
    <script src="script/html5shiv.min.js"></script>    
<![endif]-->
<script type="text/javascript">
    _userId = -1;
    _userInfo = {};
    //获取用户信息
    $.ajax({
        url: '../api/user/getUserInfo',
        type: 'GET',
        //aysnc:false,
        dataType: 'json',
        success:function(d){
            if(d.state==200){
                window._userId = d.user.id;
                window._userBaseInfo = d.user;
                window._userInfo = d.userInfo;
            }
        },
        error:function(){
            alert('获取用户信息失败，请尝试刷新');
        }
    })  
</script>
<div class="user-bar">
    <div class="wrapper">
        <div class="left">
            <?php if($r['ifLogin']){ ?>
            <span class="user">
                <a href="<?php e_page("my","index"); ?>">我的普团<i class="fa fa-caret-down"></i></a>
                <ul class="user-nav">
                    <li><a class="collect" href="<?php e_page("order","index"); ?>">我的订单</a></li>
                    <li><a class="site" href="<?php e_page("my","msg"); ?>">我的消息</a></li>
                    <li><a class="site" href="<?php e_page("my","collection"); ?>">我的收藏</a></li>
                    <li><a class="seller" href="<?php e_page("my","point"); ?>">我的积分</a></li>
                    <li><a class="seller" href="<?php e_page("my","account"); ?>">账户余额</a></li>
                    <li><a class="help" href="<?php e_page("user","loginout"); ?>">退出登录</a></li>
                </ul>
            </span>
            <a href="<?php e_page("my","point"); ?>" class="user-account">
                <span class="user-name control-user-name"><?=$r['user']['username']?></span>（<span class="user-level control-user-level"><?=$r['lv']['name']?></span>）积分 <span class="control-user-score"><?=$r['info']['point']?></span>
            </a>
            <a href="<?php e_page("cart","index"); ?>">
                <i class="fa fa-shopping-cart"></i><span class="user-name">购物车</span>
                (<span class="user-level control-cart-num"><?=$r['cart']?></span>)
            </a>
            <a href="<?php e_page("user","loginout"); ?>" class="exit">退出</a>
            <?php }else{?>
                <span class="user-name control-user-name">
                    <a href="<?php e_page('user','login') ?>" class="control-user-log">登录</a>
                </span>
                <span class="control-user-score"><a href="<?php e_page('user','login',"#register") ?>">注册</a></span>
            <?php } ?>

        </div>
        <div class="right">
            <a class="collect" href="<?php e_page("news","system","remark=toDesktop")?>"><i class="fa fa-star-o"></i>收藏/添加到桌面</a>
            <?php if($r['ifLogin']&& $r['user']['type']=='shop'){ ?>
                <a class="site" href="<?php e_url('shop','home','index') ?>">进入商家后台</a>
                <a class="site" href="<?php e_page('my','service') ?>">申请服务站</a>
            <?php }elseif($r['ifLogin']&& $r['user']['type']=='service'){?>
                <a class="seller" href="<?php e_page('my','shop') ?>">商家申请合作</a>
                <a class="site" href="<?php e_url('service','home','index') ?>">进入服务站后台</a>

            <?php }elseif($r['ifLogin']&& $r['user']['type']=='both'){?>
                <a class="site" href="<?php e_url('shop','home','index') ?>">进入商家后台</a>
                <a class="site" href="<?php e_url('service','home','index') ?>">进入服务站后台</a>
            <?php }elseif($r['ifLogin']){?>
                <a class="seller" href="<?php e_page('my','shop') ?>">商家申请合作</a>
                <a class="site" href="<?php e_page('my','service') ?>">申请服务站</a>
            <?php }else{?>
                <a class="seller" href="<?php e_page('my','shop') ?>" onclick="alert('请您登录或者是免费注册成为会员后进行申请');">商家申请合作</a>
                <a class="site" href="<?php e_page('my','service') ?>" onclick="alert('请您登录或者是免费注册成为会员后进行申请');">申请服务站</a>
            <?php } ?>
            <a class="help" href="<?php e_page("news","system","remark=help")?>"><i class="fa fa-question-circle"></i>帮助</a>
        </div>
    </div>
</div>
<script type="text/javascript">
    //barData()
    //function barData(){
    //    api.solo('cartNum',[],function(d){
    //        $('.control-cart-num').text(d.data);
    //    })
    //    api.solo('userInfo',[],function(d){
    //        $('.control-user-name').text(d.data.name)
    //        $('.control-user-level').text(d.data.level)
    //        $('.control-user-score').text(d.data.score)
    //    })
    //}

    (function(){
        $(document).ready(function($) {
            var button = $('#container > div.user-bar > div > div.left > span.user');
            var userNav = $('.user-bar .user-nav');
            button.hover(function() {
                userNav.show()
            },function(){
                userNav.hide()
            });
        });
    })()
</script>